package com.rover.system.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.grid.ViewField;



/**
 * 编码
 */
@Entity
@Table(name = "S_Code")
public class Code implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static Map<String, Code> allCode = new HashMap<String,Code>();
	public static Map<String, List<CodeValue>> allCodeValue = new HashMap<String,List<CodeValue>>();
  
    @ViewField(header = "编号", width = 200)
    private Integer id;
    @ViewField(header = "编码名称", width = 200)
    private String name;
    @ViewField(header = "描述", width = 300)
    private String description;
    @ViewField(header = "编码树", width = 60, type = "checkcolumn")
    private Integer isTree;
    @ViewField
    private String  spareProperty;
    private List<CodeValue> codeValue = new ArrayList<CodeValue>();

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "code")
    public List<CodeValue> getCodeValue() {
		return codeValue;
	}

	public void setCodeValue(List<CodeValue> codeValue) {
		this.codeValue = codeValue;
	}

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(nullable = false, unique = true)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setIsTree(Integer isTree) {
        this.isTree = isTree;
    }

    public Integer getIsTree() {
        return isTree;
    }
    @Column(length = 20)
    public String getSpareProperty() {
        return spareProperty;
    }

    public void setSpareProperty(String spareProperty) {
        this.spareProperty = spareProperty;
    }
}
